package com.tzbank.fingerPrint.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;

public class GeneralSeqNo {
	
/***
 * 	104070 FRS (AI平台)人脸识别系统
	104080 FPS (AI平台)指纹识别系统
	104090 ASR (AI平台)语音识别系统
 *  @author wangdajun
 */
	private static final int minSeqId = 1;
	private static final int maxSeqId = 999999;
	private static AtomicRangeInteger atomicRangeInteger = new AtomicRangeInteger(minSeqId, maxSeqId);
	public static String generalGlobalSeqNo(String consumer) {
		
		if("FRS".equals(consumer)) {
			consumer ="104070";
		}else if("FPS".equals(consumer)) {
			consumer ="104080";
		}else if("ASR".equals(consumer)) {
			consumer ="104090";
		}
		
		String str = new SimpleDateFormat("yyMMddHHmmss").format(new Date());
		return consumer+str+GeneralSeqNo.getSequenceId();
		
		
	}
	//同一秒内生成唯一的6位序列号  104070
	private  static synchronized String getSequenceId() {
		Integer seqId = atomicRangeInteger.incrAndGet();
		if(null == seqId) {
			atomicRangeInteger = new AtomicRangeInteger(minSeqId, maxSeqId);
			seqId = 0;
		}
		String returnStr = String.format("%06d",seqId);
		return returnStr;
	}
	
/*	public static void main(String[] args) {
		//System.out.println(generalGlobalSeqNo("FRS"));
		//ESB180614150350000002
	}*/
	
}
